import 'package:architecture/os_size.dart';
import 'package:code_preview/code_preview.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:study_demo/ui/widgets_example/text_button2.dart';

import 'text_button1.dart';

class TextButtonPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: (Text("TextButton")),
        ),
        body: Container(
          margin: EdgeInsets.all(10),
          child: Wrap(
            spacing: 20,
            children: [
              TextButton1(),
              TextButton2(),
              Container(
                  width: 80,
                  child: TextButton(
                      style: TextButton.styleFrom(
                          backgroundColor: Colors.transparent,
                          shape: RoundedRectangleBorder(),
                          side: BorderSide(color: Colors.green)),
                      onPressed: () {
                        Get.dialog(dialog('TextButtonPage'));
                      },
                      child: Text(
                        '按钮3',
                        style: TextStyle(color: Colors.green),
                      ))),
              // Container(
              //     width: 80,
              //     child: TextButton(
              //         style: TextButton.styleFrom(
              //             backgroundColor: Colors.transparent,
              //             shape: RoundedRectangleBorder(),
              //             side: BorderSide(color: Colors.green)),
              //         onPressed: () {
              //           Get.dialog(dialog('TextButtonPage'));
              //         },
              //         child: Text(
              //           '按钮4',
              //           style: TextStyle(color: Colors.green),
              //         ))),
            ],
          ),
        ));
  }
}

dialog(String className) {
  return Dialog(
      insetPadding: EdgeInsets.zero,
      backgroundColor: Colors.white,
      child: Container(
        width: windowWidth * 0.8,
        height: windowHeight * 0.8,
        padding: EdgeInsets.fromLTRB(15, 0, 15, 20),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Container(
                alignment: Alignment.center,
                height: 45,
                child:
                    Text('源码', style: TextStyle(fontWeight: FontWeight.w700))),
            Expanded(
                child: SingleChildScrollView(
                    child: CodePreview(
              className: className,
            ))),
          ],
        ),
      ));
}
